﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Data.Sqlite;
using TodoMVC.DBServices;

namespace TodoMVC.BusinessServices
{
    public class SqliteDBBusinessService
    {
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public async Task<bool> BackupDB()
        {
            try
            {
                var connStr = ConnectionHelper.GetSqliteConnectionString();
                var backupConnStr = ConnectionHelper.GetSqliteBackupConnectionString();
                var conn1 = new SqliteConnection(connStr);
                var conn2 = new SqliteConnection(backupConnStr);
                conn1.Open();
                conn1.BackupDatabase(conn2);
                conn1.Close();
                return await Task.FromResult(true);
            }
            catch (Exception ex)
            {
                return await Task.FromResult(false);
            }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public async Task<bool> RestoreDB()
        {
            return await Task.FromResult(true);
        }
    }
}
